package com.sixkey.rabbitmq;

/**
 * ClassName: RabbitService
 * Package: com.sixkey.service.impl
 * Description:
 *
 * @Author: @weixueshi
 * @Create: 2023/10/15 - 18:39
 * @Version: v1.0
 */

import lombok.RequiredArgsConstructor;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.stereotype.Service;

/**
 * 封装MQ发送消息方法
 */
@Service
@RequiredArgsConstructor
public class RabbitService {

    private final RabbitTemplate rabbitTemplate;

    /**
     *
     * @param exchange 交换机
     * @param routingKey 路由
     * @param message 消息
     * @return
     */
    public boolean sendMessage(String exchange, String routingKey, Object message){
        rabbitTemplate.convertAndSend(exchange,routingKey,message);
        return true;
    }
}
